function [QValuesSave, AbsorptionSave] = Spara2QandA_Plus(runIDs, ParameterRange, FrequencySelectRange, PolarizedDirection, FileTag, SaveFlag, TwoPeak)
    %SPARA2QANDA_PLUS 从当前打开的CST窗口，获取S参数，计算Q值和吸收值，保存在CST所在文件位置
    %@since 2022.4.21
    %@update: 增加峰值高度 增加辐射Q
    %    *参数说明*
    %       @param  [runIDs] runID向量.
    %       @param [ParameterRange] 对应的参数值变化范围.
    %       @param [FrequencySelectRange] 需要计算Q值的范围.
    %       @param [PolarizedDirection] 极化方向.
    %       @param [FileTag] 保存文件名中加入的标志.
    %       @param [SaveFlag] 是否保存文件，保存则不为0.
    %       @param [TwoPeak] 所选频率范围有两个峰是，计算第一个(-1)还是第二个(其他值).
    %       @return [QValuesSave] Q值，ID，和参数值.
    %       @return [AbsorptionSave] 频率与各个参数对应的吸收值.
    %
    %    *使用说明*
    %       无参数调用， [~,~] = SPARA2QANDA_PLUS()
    %       将按runID返回所有值，Q值默认计算第一个峰，默认频率范围请查看，极化方向为Y，不保存文件
    %
    %       [~,~]=SPARA2QANDA_PLUS(1:31,-85:5:60,[1.1,1.3],'Y','Full_Dx',0,-1)
    % ———————————————— POWERED BY YINWEI ————————————————

    %     close all;
    CST_Post = CST_MicrowaveStudio();

    if nargin == 0
        runIDs = CST_Post.getRunIDs;
        FrequencySelectRange = [1.18, 1.28];
        PolarizedDirection = 'Y';
        FileTag = [];
        SaveFlag = 0;
        TwoPeak = -1;

    end

    % [~, runIDStrings] = CST_Post.getRunIDs();
    % runIDStrings = erase(runIDStrings, '3D:RunID:');
    % runIDStrings = str2num(char(runIDStrings));
    % ParameterRange = runIDStrings(runIDs);

    QValuesSave = [];
    AbsorptionSave = [];

    for everyrun = runIDs
        % fprintf('\n------本次处理的是runID:%i------------ \n', everyrun);

        [freq, sparam, ~] = CST_Post.getSParams(everyrun);

        if PolarizedDirection == 'Y'
            [Output_Q, Output_Abp, peakValue] = Obtain_A_and_Q(sparam, freq, FrequencySelectRange);

        elseif PolarizedDirection == 'X'
            [Output_Q, Output_Abp, peakValue] = Obtain_A_and_Q(sparam(:, 3:4), freq, FrequencySelectRange);
        end

        if TwoPeak == -1
            Output_Q = Output_Q(1, :);
            peakValue = peakValue(1, :);
            QValuesSave = [QValuesSave; Output_Q, everyrun, peakValue];
        else
            Output_Q = Output_Q(end, :);
            peakValue = peakValue(end, :);
            QValuesSave = [QValuesSave; Output_Q, everyrun, peakValue];
        end

        AbsorptionSave = [AbsorptionSave, Output_Abp(1:1001)];
        fprintf(' runID:%d ----------- Q_Value:%f \n', everyrun, Output_Q);
        %         fprintf('\n-------------------------\n');
    end

    %-----------------
    % figure;
    % plot(1:length(runIDs), QValuesSave(:, 1), 'r*-', 'linewidth', 2);
    % hold on;
    % plot(1:length(runIDs), QValuesSave(:, 3), 'b--', 'linewidth', 2);
    % plot(1:length(runIDs), QValuesSave(:, 4), 'g:', 'linewidth', 2);
    % legend('Q', 'P', 'Q*P');
    % %     xlim([runIDs(1) runIDs(end)]);
    % set(gca, 'xtick', 1:length(runIDs));
    % set(gca, 'XTickLabel', ParameterRange);
    % figure;
    contourf(AbsorptionSave);
    %-----------------
    if SaveFlag

        SaveFile([freq, AbsorptionSave], [CST_Post.folder, '\Fre_Absorption_', FileTag, ], 'txt');
        SaveFile([QValuesSave, ParameterRange'], [CST_Post.folder, '\Q_', FileTag], 'txt');
        disp(['文件保存成功！'])
    end

    function [Output_Q, Output_Abp, Output_y] = Obtain_A_and_Q(sparam, freq, FrequencySelectRange)
        Absorption = 1 - abs(sparam(:, 1)).^2 - abs(sparam(:, 2)).^2;
        % Reflection = abs(sparam(:, 1)).^2 + abs(sparam(:, 2)).^2;

        IndicsRange = find(FrequencySelectRange(1) <= freq & FrequencySelectRange(2) >= freq);
        SeperatedPeak = Absorption(IndicsRange);
        SeperatedFreq = freq(IndicsRange);
        clearvars sparm freq IndicsRange

        try
            [y, x, width, ~] = findpeaks(SeperatedPeak, SeperatedFreq, 'widthreference', 'halfheight');
            [~, xx, ~, ~] = findpeaks(SeperatedPeak, 'widthreference', 'halfheight');
            Q_Value = x ./ width;
            Reflection = 1 - SeperatedPeak(xx);
            % 过阻尼
            QRadativeValue = 2 * Q_Value ./ (1 - sqrt(Reflection));
            QDisspiativeValue = 2 * Q_Value ./ (1 + sqrt(Reflection));
            Q_Value(1); % 看一下是否为空
        catch ME

            if (strcmp(ME.identifier, 'MATLAB:badsubscript'))
                fprintf('*\n*\n*\n索引超出范围，具体请查看峰的形状（已经将Q值取为INf)*\n*\n*\n')
                Q_Value = Inf;
                QRadativeValue = Inf;
                QDisspiativeValue = Inf;
                y = NaN;

            end

        end

        Output_Abp = Absorption;
        Output_Q = [Q_Value, QRadativeValue, QDisspiativeValue];
        Output_y = y;

    end

end
